import {apiClient} from "@/utils/request";


// 获取用户信息
export const getUserInfo = () => {
    return apiClient({
    url: "/users/getUserInfo",
    method: "get",
    })

}

// 用户登录
export const loginApi = (params: any) => {
    return apiClient({
        url: "/users/login",
        method: "post",
        data: params
    })
}

// 用户注册
export const registerApi = (params: any) => {
    return apiClient({
        url: "/users/register",
        method: "post",
        data: params
    })
}


// 用户退出
export const logoutApi = () => {
    return apiClient({
        url: "/users/logout",
        method: "get"
    })
}

// 修改用户信息
export const updateUserInfoApi = (params: any) => {
    return apiClient({
        url: "/users/updateUserInfo",
        method: "post",
        data: params
    })
}


// 获取用户的默认地址

export const getUserAddrApi = () => {
    return apiClient({
        url: "/users/user-address/auth/findUserAddressList",
        method: "get",
    })
}

// 调用接口获取验证码
export const getCodeApi = () => {
    return apiClient({
       url: "/users/getCaptcha",
       method: "get"
    })
 
 }

// 获取用户的全部地址
export const getAllUserAddrApi = () => {
    return apiClient({
        url: "/users/user-address/auth/getAll",
        method: "get",
    })
}

// 新增地址
export const saveUserAddressApi = (data:any) => {
    return apiClient({
        url: "/users/user-address/auth/save",
        method: "post",
        data: data
    })
}

// 根据id删除地址
export const deleteByIdUserAddrApi = (id:any) => {
    return apiClient({
        url: "/users/user-address/auth/deleteById/"+id,
        method: "delete",
    })
}



// 根据id修改地址
export const updateByIdUserAddrApi = (data:any) => {
    return apiClient({
        url: "/users/user-address/auth/update",
        method: "put",
        data: data
    })
}

